﻿using System.Activities;
using MvcFlow.Mvc.ActionResults;

namespace MvcFlow.Activities
{
    public class ViewActionResultBuilderActivity : NativeActivity<IActionResult>
    {
        public InArgument<string>   ViewName        { get; set; }
        public InArgument<string>   LayoutName      { get; set; }
        public InArgument<bool>     IsPartialView   { get; set; }
        public InArgument<object>   Model           { get; set; }

        protected override void Execute(NativeActivityContext context)
        {
            var viewActionResult = new ViewActionResult()
            {
                IsPartialView   = context.GetValue(IsPartialView),
                ViewName        = context.GetValue(ViewName),
                LayoutName      = context.GetValue(LayoutName),
                Model           = context.GetValue(Model)
            };

            Result.Set(context,viewActionResult);
        }

        public ViewActionResultBuilderActivity()
        {
            DisplayName = "ViewResult";
        }
    }
}